package com.ww.springboot.rabbitmq;

import org.apache.coyote.http11.Http11NioProtocol;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author ZH500
 */
@RestController
@SpringBootApplication
public class RabbitMqApplication implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {

    public static void main(String[] args) {
        SpringApplication.run(RabbitMqApplication.class, args);
    }

    /**
     * 想要修改最大线程数、最大连接数等配置信息 -> 自定义Web容器
     *
     * @param factory
     */
    @Override
    public void customize(ConfigurableServletWebServerFactory factory) {
//        TomcatServletWebServerFactory f = (TomcatServletWebServerFactory) factory;
//        f.setProtocol("org.apache.coyote.http11.Http11Nio2Protocol");
//
//        f.addConnectorCustomizers(c -> {
//            Http11NioProtocol protocol = (Http11NioProtocol) c.getProtocolHandler();
//            protocol.setMaxConnections(200);
//            protocol.setMaxThreads(200);
//            protocol.setSelectorTimeout(3000);
//            protocol.setSessionTimeout(3000);
//            protocol.setConnectionTimeout(3000);
//        });
    }
}